import 'dart:convert';

import 'package:ost_flutter_module/class/entity/class_entity/login_entity.dart';
import 'package:ost_flutter_module/common/defines_macro.dart';
import 'package:ost_flutter_module/help/share_preference/preferences_manager.dart';
import 'package:ost_flutter_module/network/url_constants.dart';

class GlobalCache {
  static final GlobalCache _instance = GlobalCache._internal();

  GlobalCache._internal();

  factory GlobalCache.getInstance() => _instance;

  // String _token;
  // LoginEntity _loginEntity;

  // void saveLoginEntity(LoginEntity entity) {
  //   this._loginEntity = entity;
  //   this._token = entity.accessToken;
  //   PreferencesManager.getInstance()
  //       .putString(LOGIN_DATA, json.encode(_loginEntity));
  // }

  // LoginEntity getLoginEntity() {
  //   if (_loginEntity != null) return _loginEntity;
  //   String loginJson = PreferencesManager.getInstance().getString(LOGIN_DATA);
  //   if (loginJson != null && loginJson.isNotEmpty) {
  //     _loginEntity = LoginEntity.fromJson(json.decode(loginJson));
  //     this._token = _loginEntity.accessToken;
  //     return _loginEntity;
  //   }
  //   return null;
  // }

  // void clearLoginInfo() {
  //   PreferencesManager.getInstance().putString(LOGIN_DATA, "");
  //   _loginEntity = null;
  //   _token = null;
  // }

  // String getToken() => _token;

  String getToken() => token;
}
